<template>
	<view>
		<!-- <view class="tab_nav">
			<ul>
				<li v-for="(item,index) in arrayIndex" :key="index" @click="selectTab(index)" :class="item.className">
					{{item.title}}
				</li>
			</ul>
		</view> -->
		<view class="top_select_box">
			<view class="top_select">
				<view class="left"><b @click="selectPerson">{{userData.xming0}}</b>的挂号记录</view>
				<view class="edit_icon left" @click="selectPerson"></view>
				<view class="right" @click="selectTime"><span>{{timeData.title}}</span><view class="select_icon right"></view></view>
			</view>
		</view>
		<view class="box_content">
			<ul>
				<li v-for="(item,index) in dataList" :key="index" @click="selectRecord(index)">
					<view style="padding-bottom: 10px;">
						<view><b>{{item.ghxh00}}号 {{item.yysj00}}</b><span class="right">{{item.ghsj00}}</span></view>
						<view>
							<p>就诊医生：{{item.ysmc00}}</p>
						</view>
						<view>
							<p>就诊科室：{{item.ksmc00}}</p>
						</view>
						<view>
							<p>就诊费用：{{item.ghje00}}元</p>
						</view>
					</view>
					<!-- <view class="right" v-if="item.state==1"
						style="margin-top: -65px;text-align: center;font-size: 14px;">
						<p style="color: #3692FF;">剩余支付时间</p>
						<p style="color: #3692FF;">{{item.countDown}}</p>
					</view> -->
					<view style="">
						<hr />
					</view>
					<!-- <view v-if="item.state==2" class="right list_footer" style="color: #3692FF!important;">
						等待就诊
					</view>
					<view v-if="item.state==3" class="right list_footer">
						<p>已就诊</p>
					</view>
					<view v-if="item.state==4" class="right list_footer">
						<p>超时未就诊</p>
					</view>
					<view v-if="item.state==1" class="btns list_footer">
						<button class="box_btn pay_btn" @click.stop="payment(item)">支付挂号费</button>
						<button class="box_btn cancel" @click.stop="cancel(item)">取消挂号</button>
					</view> -->
				</li>
			</ul>
		</view>
		<dateTimeSelect styles="display:none;" ref="dateTimeSelect" v-on:checked= "getTime"></dateTimeSelect>
		<personList styles="display:none;" ref="personList" v-on:checkedPerson= "getDatas"></personList>
	</view>
</template>

<script>
	import dateTimeSelect from "../../modules/dateTimeSelect.vue";
	import personList from "../../modules/personList.vue";
	export default {
		data() {
			return {
				arrayIndex: [{
					"title": "全部",
					"className": "checked_nav"
				}, {
					"title": "未就诊",
					"className": ""
				}, {
					"title": "已就诊",
					"className": ""
				}],
				userData:{xming0:""},
				dataList: [],
				timeData:{title:"默认"}
			}
		},
		components:{
			personList,dateTimeSelect
		},
		onLoad() {
		},
		methods: {
			init(userData){
				let user=uni.getStorageSync("user");
				if(userData){
					user=userData;
				}
				this.userData=user;
				let data={
					"kh0000":user.sfzh00,
					"klx000":"3",//卡类型
					"ksrq00":this.timeData.startDate,//开始日期（格式：yyyy-MM-dd）
					"jzrq00":this.timeData.endDate,//截止日期（格式：yyyy-MM-dd）
					"patid0":user.patid0,//患者ID
					"ghlx00":"3",//
					"funid":"F07.09.02.07",
					"ywlsh0":""+new Date().getTime()
					
				}
				uni.showLoading({
					mask:true,
					title:"数据加载中..."
				})
				this.$postJson("/qnyesb/qnyesbproxy",data,res=>{
					if(res.state==0){
						//加载列表成功
						this.dataList=res.data.retrieve;
					}else{
						uni.showModal({
							title:"温馨提示",
							content:res.message+"~点击确定返回首页",//queryRes.message
							mask:true,
							showCancel:false,
							success(showRes) {
								if(showRes.confirm){
									uni.switchTab({
										url:"../index/index"
									})
								}
							}
						})
					}
					uni.hideLoading();
				})
			},
			selectTab(index) {
				//顶部栏目
				console.log(index);
				let length = this.arrayIndex.length;
				for (let i = 0; i < length; i++) {
					this.arrayIndex[i].className = "";
				}
				this.arrayIndex[index].className = "checked_nav";
				// if (index == 0) {
				// 	//全部
				// } else if (index == 1) {
				// 	//待就诊
				// } else if (index == 2) {
				// 	//已就诊
				// }
				this.init(index);
			},
			selectRecord(){
				//记录选中，进入详情页
			},
			payment(item){
				console.log("测试的");
			},
			cancel(item){
				let data={
					"kh0000":item.kh0000,
					"klx000":"3",//卡类型
					"patid0":"20220209000855",//患者ID
					"yylsh0":item.yylsh0,//预约状态（1未就诊；2已就诊；3已取消；0全部）
					"funid":"F07.09.02.09",
					"ywlsh0":""+new Date().getTime()
					
				}
				this.$postJson("/qnyesb/qnyesbproxy",data,res=>{
					if(res.state==200){
						uni.showToast({
							icon:"success",
							title:"取消成功"
						});
					}else{
						uni.showToast({
							title:res.message,
							icon:"none"
						})
					}
				})
				
			},
			selectTime(){
				this.$refs.dateTimeSelect.select();
			},
			getTime(item){
				this.timeData=item;
				this.init();
			},
			selectPerson(){
				this.$refs.personList.selectPerson();
			},
			getDatas(item){
				this.userData=item;
				this.init();
			},
		}
	}
</script>

<style>
	.tab_nav {
		position: fixed;
		width: 100%;
		display: flex;
		top: 0px;
		z-index: 99999999;

	}

	.tab_nav ul {
		padding: 10px;
		width: 65%;
		margin: 0 auto;
	}

	.tab_nav ul li {
		float: left;
		margin-left: 30px;

	}

	.tab_nav ul .checked_nav {
		border-bottom: 4px solid #3692FF;
		color: #3692FF;
	}

	.box_content {
		width: 96%;
		margin: 0 auto;
	}

	.box_content p {

		color: #999999;
	}

	.box_content hr {
		border: 1px solid #F0F0F0;
	}

	.box_content ul li {
		width: 89%;
		background-color: #FFFFFF;
		padding: 20px;
		margin-top: 10px;
		display: inline-block;
		line-height: 30px;
		padding-bottom: 10px;
	}

	.box_content .btns {
		margin-top: 10px;
	}

	.box_content .btns .box_btn {
		width: 94px;
		height: 30px;
		border-radius: 15px;
		font-size: 14px;
		border: none;
		float: right;
		line-height: 30px;
		margin-right: 10px;
	}

	.box_content .btns .pay_btn {
		background-color: #3692FF;
		color: #FFFFFF;
		margin-right: 0px;
	}

	.list_footer {
		padding-top: 5px;
	}
</style>
